<template>
  <el-dialog title="班级列表"
             :visible.sync="dialogShow"
             width="30%"
             @close="closeDialog">
    <div v-for="item in formData"
         :key="item.id">
      <br />
      <el-radio v-model="list"
                :label="item">{{ item.class_name }}</el-radio>
    </div>

    <div slot="footer">
      <el-button type="primary"
                 @click.native="btnOk">确定</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { getBindClassApi } from "@/api/exam";
export default {
  name: "ClassExam",
  data () {
    return {
      dialogShow: false,
      formData: [],
      list: [],
      exam_id: "",
      main_paper_id: "",
    };
  },

  methods: {
    async btnOk () {
      if (this.list.length === 0) {
        return (this.dialogShow = false);
      }
      await getBindClassApi({
        class_id: this.list.id,
        exam_id: this.exam_id,
        main_paper_id: this.main_paper_id,
      });
      this.$message.success("推送成功");
      this.dialogShow = false;
      this.$emit("updateList");
    },
    closeDialog () {
      this.dialogShow = false;
      this.list = [];
      this.exam_id = "";
      this.main_paper_id = "";
    },
  },
};
</script>

<style></style>
